!pr0
!lm12
!rm75
Large Source Files and the S-C Macro Assembler......Bill Morgan

One of the more common questions we get is:  "How do I best use the .IN and .TF directives to handle very large programs?"

The main technique we use is the Assembly Control File (ACF), a short source file which is mostly made up of .IN statements to call the other modules.  Here is an example, called SAMPLE.ACF:

!lm+5
1000       .IN SAMPLE.EQUATES
1010       .PG
1020       .IN SAMPLE.CODE.1
1030       .PG
1040       .IN SAMPLE.CODE.2
1050       .PG
1060       .IN SAMPLE.DATA
1070       .PG
!lm-5

SAMPLE.EQUATES is all the definitions for the program, SAMPLE.CODE.1 and SAMPLE.CODE.2 are the main body of the program, and SAMPLE.DATA contains all the variables and ASCII text.  When you want to assemble the program, just LOAD SAMPLE.ACF and type MON C then ASM.  The Macro Assembler will load each file and assemble it, in the order they are listed in the ACF.  The "MON C" shows you the "LOAD file name" for each file, helping you to tell what's where.

Using this technique, a program can conveniently be broken into as many modules as you want, and can be as large as you want.  The Macro Assembler itself is 26 source files on two disks!  To spread the files across more than one disk, just add drive (and/or slot) specifiers to all the file names.

You can also use the ACF to do global search-and-replace operations on the entire program.  Here are the commands to search SAMPLE for all occurences of the label MON.COUT:

!lm+5
:LOAD SAMPLE.ACF
:REP /       .IN/LOAD/A
:REP /       .PG/FIND "MON.COUT"/A
:TEXT COUT.SEARCH
:MON I
:EXEC COUT.SEARCH
!lm-5

This converts SAMPLE.ACF into an EXEC file that will list each occurence of "MON.COUT" in every module of the program.  Here's what the file looks like now:

!lm+5
1000 LOAD SAMPLE.EQUATES
1010 FIND "MON.COUT"
1020 LOAD SAMPLE.CODE.1
1030 FIND "MON.COUT"
1040 LOAD SAMPLE.CODE.2
1050 FIND "MON.COUT"
1060 LOAD SAMPLE.DATA
1070 FIND "MON.COUT"
!lm-5
!np
The ACF is also a good place for the .OR and .TF statements, comments about the assembly process, and any condition flags.  Here is a more complicated version of SAMPLE.ACF:

!lm+5
1000 *--------------------------------
1010 *      SAMPLE FILE TO DEMONSTRATE ACF
1020 *--------------------------------
1030 LC.FLAG .EQ 0  =0 IF UPPER CASE ONLY
1040 *              =1 IF LOWER CASE VERSION
1050 *--------------------------------
1060        .OR $803
1070        .DO LC.FLAG
1080        .TF B.SAMPLE.LC
1090        .ELSE
1100        .TF B.SAMPLE.UC
1110        .FIN
1120 *--------------------------------
1130        .IN SAMPLE.EQUATES
1140        .PG
1150        .IN SAMPLE.CODE
1160        .PG
1170        .DO LC.FLAG
1180        .IN SAMPLE.LOWER.CASE.ROUTINES
1190        .PG
1200        .ELSE
1210        .IN SAMPLE.NORMAL.ROUTINES
1220        .PG
1230        .FIN
1240        .IN SAMPLE.DATA
1250        .PG
!lm-5

To use this ACF, just LOAD it, EDIT line 1030 to set LC.FLAG to 0 or 1, set MON C, and ASM.  The Macro Assembler will load the appropriate source files for the version you want and direct the object code to the correct target file.  To turn this ACF into an EXEC file for searching, you must delete lines 1000-1120, 1170, 1200, and 1230 before doing the REP commands.

For more information on the .IN and .TF directives, see pages 4-6 and  5-3/4 in the Macro Assembler manual.  Conditional assembly is discussed on pages 5-9/10 and in chapter 7.
